package pt.ipl.isel.deetc.leic.pdm.g12.yamba;

import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;

public class UserInfo implements Parcelable{
	String screenName;
	int status, subscriptions, subscribers;
	BitmapDrawable profilePicture;
	
	public UserInfo(){}
	
	public UserInfo(String screenName, int status, int subscriptions, int subscribers, BitmapDrawable profilePicture) {
		super();
		this.screenName = screenName;
		this.status = status;
		this.subscriptions = subscriptions;
		this.subscribers = subscribers;
		this.profilePicture = profilePicture;
	}
	
	public UserInfo(Parcel in) {
		readFromParcel(in);
	}

	public String getScreenName() {
		return screenName;
	}

	public int getStatus() {
		return status;
	}

	public int getSubscriptions() {
		return subscriptions;
	}

	public int getSubscribers() {
		return subscribers;
	}

	public Drawable getProfilePicture() {
		return profilePicture;
	}

	public int describeContents() {
		return 0;
	}

	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(screenName);
		dest.writeInt(status);
		dest.writeInt(subscriptions);
		dest.writeInt(subscribers);
		
		Bitmap bitmap = (Bitmap)((BitmapDrawable) profilePicture).getBitmap();
		dest.writeParcelable(bitmap, flags);
	}
	
	private void readFromParcel(Parcel in) {
		screenName = in.readString();
		status = in.readInt();
		subscriptions = in.readInt();
		subscribers = in.readInt();
		
		Bitmap bitmap = (Bitmap)in.readParcelable(getClass().getClassLoader());
		profilePicture = new BitmapDrawable(bitmap);
	}
	
	public static final Parcelable.Creator<UserInfo> CREATOR =
	    	new Parcelable.Creator<UserInfo>() {
	            public UserInfo createFromParcel(Parcel in) {
	                return new UserInfo(in);
	            }
	 
	            public UserInfo[] newArray(int size) {
	                return new UserInfo[size];
	            }
	        };
}
